var t = (0, require("../../../@babel/runtime/helpers/interopRequireDefault").default)(require("../../../utils/util")),
  a = new(require("../../../utils/http").HTTP);
Page({
  data: {
    nowtime: t.default.formatDate(new Date),
    password: t.default.randomRange(7)
  },
  onLoad: function (t) {
    wx.setNavigationBarTitle({
      title: t.xm
    });
    var e = wx.getStorageSync("ssid"),
      d = wx.getStorageSync("openid"),
      n = this;
    a.request({
        url: "https://www.qlsyyun.com:3030/serve/category",
        data: {
          arr: 1,
          kind: "招商业务"
        }
      }).then((function (t) {
        n.setData({
          list: t.data[0]
        })
      })),
      n.setData({
        listId: t.listId,
        name: t.xm,
        ssid: e,
        openid: d
      })
  },
  getName: function (t) {
    this.setData({
      inputname: t.detail.value
    })
  },
  getNumber: function (t) {
    this.setData({
      phone: t.detail.value
    })
  },
  getNeed: function (t) {
    this.setData({
      notes: t.detail.value
    })
  },
  apply: function () {
    var t = this;
    null == t.data.inputname ? wx.showToast({
      title: "请填写姓名",
      icon: "none",
      duration: 1e3
    }) : /^1[3456789]\d{9}$/.test(t.data.phone) ? (a.request({
      url: "https://www.qlsyyun.com:3030/add/sqrlb",
      data: {
        ssid: t.data.ssid
      }
    }).then((function (e) {
      t.setData({
          rzbh: e.data[0].bhrz,
          khbhkh: e.data[0].khbh
        }),
        a.request({
          url: "https://www.qlsyyun.com:3030/add/gdmx",
          header: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          method: "POST",
          data: {
            arr: 2,
            gs: "自营",
            ywlb: t.data.list.ywlb,
            bm: t.data.list.bm,
            slr: t.data.list.slr,
            xq: t.data.notes,
            sqrname: t.data.inputname,
            sqrphone: t.data.phone,
            tname: t.data.inputname,
            tjsj: t.data.nowtime,
            ywlba: t.data.name,
            ywlbc: "项目预约",
            sqrlb: t.data.rzbh,
            gdbh: t.data.password,
            openid: t.data.openid,
            khbhkh: t.data.khbhkh
          }
        }).then((function (e) {
          a.request({
            url: "https://www.qlsyyun.com:3030/add/gdmxid",
            data: {
              gdbh: t.data.password
            }
          }).then((function (e) {
            a.request({
                url: "https://www.qlsyyun.com:3030/add/gdmxjd",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  gdid: e.data[0].gdmxID,
                  gdbh: t.data.password,
                  ywlb: t.data.list.ywlb,
                  slr: t.data.list.slr,
                  tjsj: t.data.nowtime,
                  tname: t.data.inputname,
                  khbhkh: t.data.khbhkh
                }
              }).then((function (t) {})),
              a.request({
                url: "https://www.qlsyyun.com:3030/add/gdtx",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  gdid: e.data[0].gdmxID,
                  gdbh: t.data.password,
                  tnamea: t.data.list.slr,
                  slr: t.data.list.slr,
                  tnameb: " ",
                  tjsj: t.data.nowtime,
                  tname: t.data.inputname,
                  gs: "自营",
                  khbhkh: t.data.khbhkh
                }
              }).then((function (t) {}))
          }))
        }))
    })), wx.navigateTo({
      url: "/pages/employ/success/success?name=" + t.data.name + "&type=" + t.data.phone + "&time=" + t.data.nowtime
    })) : wx.showToast({
      title: "手机号格式不正确",
      icon: "none",
      duration: 1e3
    })
  }
});